using System.Collections;
using Holoville.HOTween;
using Holoville.HOTween.Core;
using UnityEngine;

public class OnChargeBullet : OnChargeObj
{
	[SerializeField]
	private bool setOnEndPosition;

	public float scaleFactor;

	public override IEnumerator UpdateCharge()
	{
		base.transform.SetParent(null);
		if (!setOnEndPosition)
		{
			base.transform.position = start;
			HOTween.To(base.transform, Vector3.Distance(end, start) / speed, new TweenParms().Prop("position", end).Ease(EaseType.Linear).OnComplete((TweenDelegate.TweenCallback)delegate
			{
				Invoke("DestroyAfterDelay", lifeTime);
			}));
			yield break;
		}
		LineTracer tracer = GetComponent<LineTracer>();
		if ((bool)tracer)
		{
			tracer.AnimateLenght(start, end, speed, scaleFactor);
			Object.Destroy(tracer.gameObject, lifeTime);
		}
	}

	private void DestroyAfterDelay()
	{
		Object.Destroy(base.gameObject);
	}
}
